<?php
    require_once("condb.php");
    require_once("functions.php");
    
    $output = array();
    $info = isset($_GET["info"]) ? $_GET["info"] : "";
    if(!empty($info)){
        $info = urldecode(base64_decode($info));
        parse_str($info, $request);    
        
        $token = isset($request["token"]) ? cleanQuery($request["token"]) : "";
        if($token=="TAoViEC@)!#2012"){
            
            /*
            * Lấy cú pháp sms
            */
            
            $syntax = getSmsSyntax();            
            
            $data = array();
            $data["refCode"] = isset($request["refCode"]) ? cleanQuery($request["refCode"]) : "";            
            $data["appId"] = isset($request["appId"]) ? intval($request["appId"]) : 0;            
            
            if(!empty($data["refCode"]) && !empty($data["appId"])){
                
                $sms[0]["message"] = "Nhắn tin kích hoạt";
                $sms[0]["mo"] = $syntax[7]["syntax"] . " 5 " . $data["appId"] . " " . $data["refCode"];
                $sms[0]["serviceCode"] = "6022";//$syntax[7]["serviceCode"];                
                
                $sms[1]["message"] = "Nhắn tin kích hoạt soi cầu";
                $sms[1]["mo"] = $syntax[8]["syntax"] . " 5 " . $data["appId"] . " " . $data["refCode"];
                $sms[1]["serviceCode"] = "6022";//$syntax[8]["serviceCode"];                
                
                $sms[2]["message"] = "Nhắn tin kích hoạt quay thử";
                $sms[2]["mo"] = $syntax[9]["syntax"] . " 5 " . $data["appId"] . " " . $data["refCode"];
                $sms[2]["serviceCode"] = "6022";//$syntax[9]["serviceCode"];                
                
                $sms[3]["message"] = "Nhắn tin kích hoạt cầu may";
                $sms[3]["mo"] = $syntax[10]["syntax"] . " 5 " . $data["appId"] . " " . $data["refCode"];
                $sms[3]["serviceCode"] = "6022";//$syntax[10]["serviceCode"];                
                
                $sms[4]["message"] = "Nhắn tin kích hoạt sổ mơ";
                $sms[4]["mo"] = $syntax[11]["syntax"] . " 5 " . $data["appId"] . " " . $data["refCode"];
                $sms[4]["serviceCode"] = "6022";//$syntax[11]["serviceCode"];                
                                    
                $output["status"] = 1;
                $output["msg"] = "Success Request";
                    
            } else {
                $output["status"] = 4;
                $output["msg"] = "Truyen thieu params";                        
            }
                
        } else {
            $output["status"] = 3;
            $output["msg"] = "Sai Token";    
        }
    } else {
        $output["status"] = 2;
        $output["msg"] = "Invalid Request";
    }
    
    $output["sms"] = isset($sms) ? $sms : array();        
    echo json_encode($output);
?>